<template>
  <div class="app">
    <p><img alt="Vue logo" src="./assets/logo.png"></p>
    <p><input v-model="inputText" type="text" placeholder="输入内容..." /></p>

    <!-- 把 msg 传给 HelloWorld，并监听 @clear 事件 -->
    <HelloWorld :msg="inputText" @clear="clearInput" />
  </div>
</template>

<script>
import HelloWorld from './components/HelloWorld.vue'

export default {
  name: 'App',
  components: {
    HelloWorld
  },
  data() {
    return {
      inputText: ''
    }
  },
  methods: {
    clearInput() {
      this.inputText = ''
    }
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}

input {
  padding: 8px;
  margin: 10px;
  font-size: 16px;
}
</style>
